package com.gaoshi.chapter4;

import java.util.Arrays;
import java.util.Scanner;

public class LotteryDrawing {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        System.out.println("How many numbers do you need to draw?");
        int n = in.nextInt();

        System.out.println("What is the highest number you can draw?");
        int r = in.nextInt();

        int[] numbers = new int[r];
        for (int i = 1; i <= r; i++) {
            numbers[i - 1] = i;
        }

        int[] results = new int[n];
        for (int i = 0; i < results.length; i++) {
            int n1 = (int) (Math.random() * r);
            results[i] = numbers[n1];
            numbers[n1] = numbers[r - 1];
            r--;
        }

        System.out.println(Arrays.toString(numbers));
        System.out.println(Arrays.toString(results));
    }
}
